//package com.wangnaiqi.pulsar.config;
//
//import com.wangnaiqi.pulsar.entidy.User;
//import org.apache.pulsar.client.api.*;
//import org.apache.pulsar.client.impl.schema.JSONSchema;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//
//import java.util.concurrent.TimeUnit;
//
///**
// * @author wangnaiqi
// * @description pulsar生产者配置
// * @date 2023/12/13
// */
//@Configuration
//public class PulsarProducerConfig {
//
//    @Value("${pulsar.topic.name.test-topic-name}")
//    String topicName;
//
//    @Value("${pulsar.topic.name.test2-topic-name}")
//    String topicName2;
//
//    @Autowired
//    PulsarClient pulsarClient;
//
//    @Bean
//    public Producer<String>  getStringProducer() {
//        ProducerBuilder<String> stringProducerBuilder = pulsarClient.newProducer(Schema.STRING)
//                .topic(topicName)
//                .sendTimeout(60, TimeUnit.SECONDS);
//
//        Producer<String> producer = null;
//        try {
//            producer = stringProducerBuilder.create();
//        } catch (PulsarClientException e1) {
//            e1.printStackTrace();
//        }
//        return producer;
//    }
//
///*    @Bean
//    public Producer<User>  getUserProducer() {
//        ProducerBuilder<User> stringProducerBuilder = pulsarClient.newProducer(JSONSchema.of(User.class))
//                .topic(topicName2)
//                .sendTimeout(60, TimeUnit.SECONDS);
//
//        Producer<User> producer = null;
//        try {
//            producer = stringProducerBuilder.create();
//        } catch (PulsarClientException e1) {
//            e1.printStackTrace();
//        }
//        return producer;
//    }*/
//}
